import { defineConfig } from 'vite'
import dts from 'vite-plugin-dts'
import { removeDirSync } from '@lhy-assist/node'

removeDirSync('lib/types')
export default defineConfig({
  plugins: [
    dts({
      include: ['src/qiankun/**/*.ts'],
      root: '.',
      outputDir: 'lib/types',
      tsConfigFilePath: './tsconfig.json',
      insertTypesEntry: false,
      copyDtsFiles: false,
      staticImport: true,
      skipDiagnostics: true,
    }),
  ],
  resolve: {
    alias: [
      {
        find: /@\//,
        replacement: '/src/',
      },
    ],
  },
  build: {
    rollupOptions: {
      input: {
        'platform-frame-lib': 'src/qiankun/frame-lib.ts',
      },
      output: {
        dir: 'lib/dist',
        entryFileNames: `[format]/[name].js`,
        chunkFileNames: `[format]/chunks/[name].js`,
      },
    },
  },
})
